package com.kaishengit.web;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.kaishengit.entity.Document;
import com.kaishengit.entity.DocumentComment;
import com.kaishengit.service.DocumentCommentService;
import com.kaishengit.service.DocumentService;
import com.kaishengit.util.web.ServletUtil;


public class DocumentShowServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String id = request.getParameter("id");
		
		List<DocumentComment> list = new DocumentCommentService().findByDocumentId(Integer.parseInt(id));
		
		Document document = new DocumentService().findById(Integer.parseInt(id));
		request.setAttribute("documentComment", list);
		request.setAttribute("document", document);
		ServletUtil.forword(request, response, "documentShow");
	}
}
